#ifndef TEMPLATEEDITORDIALOG_H
#define TEMPLATEEDITORDIALOG_H

#include <QDialog>
#include <QVBoxLayout>
#include <QHBoxLayout>
#include <QFormLayout>
#include <QLineEdit>
#include <QPushButton>
#include <QLabel>
#include <QMessageBox>
#include <QWidget>
#include "billtemplate.h"

class TemplateEditorDialog : public QDialog
{
    Q_OBJECT
    
public:
    explicit TemplateEditorDialog(QWidget *parent = nullptr, BillTemplate* temp = nullptr);
    
    BillTemplate getTemplate() const;
    
private slots:
    void addNewField();
    void removeField(QWidget* widget);
    void saveTemplate();
    
private:
    void initUI();
    void addFieldRow(const FieldInfo& field = FieldInfo());
    
    BillTemplate templateObj;
    QWidget* fieldList;
    QVBoxLayout* fieldListLayout;
    QLineEdit* nameEdit;
    QLineEdit* widthEdit;
    QLineEdit* heightEdit;
};

#endif // TEMPLATEEDITORDIALOG_H
